package com.tedu.bill.demo4;

/**
 * Author：毕龙
 * Date: 2024/4/25 20:17
 */
public class TestFindStudent {
    public static void main(String[] args) {
        //数组直接初始化
        Student[] students = {
                new Student("代琦", "男", 18, 89),
                new Student("子枭", "男", 20, 79),
                new Student("朱琳", "女", 21, 69),
                new Student("金草", "女", 22, 59),
                new Student("子荣", "男", 23, 99)
        };

        //调用赵学成成绩是79
        Student student = findStudent(students);
        System.out.println(student);
        student = findStudent(students,99);
        System.out.println(student);
        student = findStudent(students,69,"女");
        System.out.println(student);
    }

    //找个学生成绩是79
    public static Student findStudent(Student[] students){
        for (int i = 0; i < students.length; i++) {
            if(students[i].getScore() == 79){
                return students[i];
            }
        }
        return null;
    }

    //找个学生成绩是79
    public static Student findStudent(Student[] students,double score){
        for (int i = 0; i < students.length; i++) {
            if(students[i].getScore() == score){
                return students[i];
            }
        }
        return null;
    }

    //找个学生成绩是79
    public static Student findStudent(Student[] students,double score,String sex){
        for (int i = 0; i < students.length; i++) {
            if(students[i].getScore() == score && students[i].getSex().equals("女")){
                return students[i];
            }
        }
        return null;
    }
}
